Remove the RemoteFactory class from the python module#4059
Conversation
| from pacemaker._cts import logging | ||
|
|
||
|
|
||
| def convert2string(lines): |
There was a problem hiding this comment.
Additionally, it's unclear to me that this was actually useful in the
first place. We were logging the byte strings before converting them to
text.
Well... sort of. With verbose == 2, __call__() was logging stdout (as result) as UTF-8. But it was logging stderr (as errors) as bytes. As for AsyncCmd.run(), it was logging stdout and stderr as bytes, but then it was passing them to async_complete() as text.
I think what you're doing here is fine -- do everything as text. I'm just clarifying what was happening before, if I'm reading it correctly.
| def __init__(self): | ||
| """Create a new RemoteExec instance.""" | ||
|
|
||
| # @TODO This should be an argument list that gets used with subprocess, |
There was a problem hiding this comment.
No need to do this now, but it looks pretty straightforward, even if tedious.
As an intermediate step, you could even use shlex.split() to split a command string into a list. Then you could pass it to subprocess.X. Not necessary now unless you want to.
It's perfectly valid for PCMK__XA_LRMD_QUEUE_TIME to be zero. This gets set in send_cmd_complete_notify by execd where it's defined by the time the command started running minus the time it was enqueued. If the command never started running because it was canceled first, then queue time can be negative. This most often comes up in a handful of cts-exec regression tests. I don't think it's causing any actual problem, but assertions in log files are always worth investigating and removing. Fixes T1009
It's always False. Ref T680
There's no need for these functions now that they're just pass throughs. Ref T680
It's only ever True in one place, and I don't think I care about that. We can just always log. Ref T680
It defines some fairly common function names like "run" that I want to use, so it makes sense to import the whole module and force us to do "subprocess.popen" instead.
This is only ever used in one place. It can just be an argument array instead. And while I'm at it, do what the TODO suggested and use subprocess instead. Ref T680
If we pass universal_newlines=True when we create a Popen object, the resulting streams will be text instead of bytes (when we support python >= 3.7, this is also called text=True). Additionally, it's unclear to me that this was actually useful in the first place. We were logging the byte strings before converting them to text. Ref T680
This is also used in one place, so just define it as a private variable in the class itself. Note that it would really make a lot of sense to also have this be a list of arguments, but in order to do that properly we also need to change everywhere that runs a command to pass a list as well. That's a project for another day. Ref T680
* It completely duplicates what the async_call method does. * There's one caller in LogAudit that was using it totally incorrectly. verbose=0 doesn't matter because that argument was never getting passed to AsyncCmd, so it would log however it wanted regardless. And, rc would always be 0 because we don't wait around for the process to give us a valid return code so the error message would never be logged. Ref T680
This doesn't really do anything interesting now. It just returns the singleton instance of RemoteExec, but I don't think there's much savings to be had in doing this instead of just creating a new instance each time. It's not a very complicated class with lots of variables that take time to set up. This also allows us to get rid of all of the pylint not-callable pragmas since that level of indirection has been removed. Ref T680
|
CI failure is unrelated, but probably still worth looking into. |
I don't know if there's any reason to use one over the other, but personally I like the more explicit function name. Ref T680
What we really care about here is whether or not one system can ssh into another, so all we need to do is just try to ssh without all those extra options. Ref T680
In general, you definitely want to do host key checking and this option is set to "ask" by default. However, in CTS, this means that if you haven't ssh'd between systems first and done host key checking (or at least responded to the ssh prompt), it will stop and ask. This results in test case failures. So add this argument to just skip the host key checking and prevent those failures. I think this is reasonable to do in CTS, but obviously you wouldn't want to do this elsewhere.
This fixes a pylint warning regarding naming.
TCPKeepAlive=yes and ServerAliveCountMax=3 are ssh defaults, and appear to have been ssh defaults for a very long time. The only reason to specify these would be if you had your ctslab machines configured differently, which I don't expect anyone is doing. Thus we can just remove these.
No description provided.